import 'package:aio/aio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/http_data.dart';
import 'package:app/src/http/bean/wroks/address_bean.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/ui/app_ui.dart';
import 'package:app/src/ui/route/helper/route_helper.dart';
import 'package:app/src/ui/route/works/public/items/ui_base.dart';
import 'package:app/src/ui/route/works/public/items/ui_card.dart';

import '../../../../../../http/bean/worksdo/equipment_management_bean.dart';
import '../../../../../../http/bean/worksdo/material_requisition_bean.dart';
import '../../../../../../http/bean/wroks/dispatchingaudit_bean.dart';
import '../../../../../../http/model/config_model.dart';
import '../../../../../dialog/dailog.dart';

///二级设备信息
class UiTicketCenter2 {
  ///data 信息
  ///oldData 历史信息
  ///isPurStartDate 是否显示请购日期
  static Widget build(BuildContext context, EquipmentInfo? data,
      EquipmentInfo? oldData, StateSetter setState,
      {String? title, bool isPurStartDate = true}) {
    if (data == null) {
      return AppUi.getEmptyView();
    }
    if (data.isLv1()) {
      return AppUi.getEmptyView();
    }
    List<Widget> children = [];
    if (StringUtils.isEmpty(title)) {
      title = AppStrings.of(context).Secondarydeviceinformation; //二级设备信息
    }
    children.add(UiBase.title(context, title)); //标题
    var isAllowEmpty = true;
    var isGrey = false;
    var defaultValue = ""; //文本为空时，显示默认文本。
    children.add(UiBase.item(context, AppStrings.of(context).DCode2,
        data?.EquipmentCode2, oldData?.EquipmentCode2,
        isAllowEmpty: isAllowEmpty,
        defaultValue: defaultValue,
        isGrey: isGrey)); //二级设备编码
    children.add(UiBase.item(context, AppStrings.of(context).DName2,
        data?.EquipmentName2, oldData?.EquipmentName2,
        isAllowEmpty: isAllowEmpty,
        defaultValue: defaultValue,
        isGrey: isGrey)); //二级设备名称
    ///工单号和工单类型，那个设备维修就显示在哪一级。
    if (data.isLv2()) {
      children.add(UiBase.item(context, AppStrings.of(context).TicketNo,
          data?.RepairNo, oldData?.RepairNo,
          isAllowEmpty: isAllowEmpty,
          defaultValue: defaultValue,
          isGrey: isGrey)); //工单号
      children.add(UiBase.item(context, AppStrings.of(context).Workordertype,
          data?.getRepairTypeName(context), oldData?.getRepairTypeName(context),
          isAllowEmpty: isAllowEmpty,
          defaultValue: defaultValue,
          isGrey: isGrey)); //工单类型
    }
    var column = UiBase.column(context, children);
    var card = UiCard.build(context, column);
    return card;
  }
}
